]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
util: Don't consider consecutive dots as URLs
authorSebastian Keller <skeller@gnome.org>
Tue, 15 Jul 2025 08:08:45 +0000 (10:08 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 1 Aug 2025 14:29:16 +0000 (16:29 +0200)
This now requires at least one character separating each dot for it to
be considered a URL. It also does not allow URLs starting with a dot
anymore.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8517
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3798>
(cherry picked from commit 5af26a21810cdc26965137d5c30864ad782db5b6)

js/misc/util.js
tests/unit/url.js

index 0a6bf19327fb47efb469c050e95bf5debac4dc74..0101ecffbddb3100413452e396107cfcf38f8e39 100644 (file)
@@ -20,7 +20,7 @@ const _urlRegexp = new RegExp(
             '|' +
             'www\\d{0,3}[.]' +                    // www.
             '|' +
-            '[a-z0-9.\\-]+[.][a-z]{2,4}/' +       // foo.xx/
+            '([a-z0-9\\-]+[.])+[a-z]{2,4}/' +     // foo.xx/
         ')' +
         '(?:' +                                   // one or more:
             '[^\\s()<>]+' +                       // run of non-space non-()
index 28ef0fa284994f7fd555cd96803a2850ebc05032..0542565d879a879feaeacf8f0827e291e9ba568d 100644 (file)
@@ -53,6 +53,14 @@ describe('findUrls()', () => {
             input: 'This is a www.gnome.org/scheme-less test.',
             output: [{url: 'www.gnome.org/scheme-less', pos: 10}],
         },
+        {
+            input: 'This is a gnome.org/scheme-less test without www.',
+            output: [{url: 'gnome.org/scheme-less', pos: 10}],
+        },
+        {
+            input: 'This is a status.gnome.org/scheme-less test.',
+            output: [{url: 'status.gnome.org/scheme-less', pos: 10}],
+        },
         {
             input: 'This is a http://www.gnome.org:99/port test.',
             output: [{url: 'http://www.gnome.org:99/port', pos: 10}],
@@ -104,6 +112,18 @@ describe('findUrls()', () => {
             input: 'This is surely@not.a/url test.',
             output: [],
         },
+        {
+            input: 'This is not..aa/url test.',
+            output: [],
+        },
+        {
+            input: 'This is ..not/a-url test.',
+            output: [],
+        },
+        {
+            input: 'This is .absolutely.not/a-url test.',
+            output: [],
+        },
     ];
 
     for (const param of urlParameters) {